Skip to content

Add access modifier to VolumeVO#9394

Merged
weizhouapache merged 2 commits intoapache:4.20from
scclouds:add-access-modifiers-to-VolumeVO
Dec 6, 2024
Merged

Add access modifier to VolumeVO#9394
weizhouapache merged 2 commits intoapache:4.20from
scclouds:add-access-modifiers-to-VolumeVO

Conversation

@FelipeM525
Copy link
Contributor

Description

The class VolumeVO lacks access modifiers in its fields. This PR aims to improve adherence to object-oriented programming by adding private access modifiers to all fields in the class mentioned above, along with their respective getters and setters. I've also added a getter to an occurrence in VolumeApiServiceImpl where a field belonging to VolumeVO was being accessed directly.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI

Feature/Enhancement Scale

  • Major
  • Minor

How Has This Been Tested?

I ran all the tests related to VolumeVO and VolumeApiServiceImpl, checked all usages of both classes, and made sure nothing was broken.

@codecov
Copy link

codecov bot commented Jul 15, 2024

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 15.81%. Comparing base (15e25bc) to head (67dbfe3).
Report is 139 commits behind head on 4.20.

Files with missing lines Patch % Lines
...hema/src/main/java/com/cloud/storage/VolumeVO.java 0.00% 2 Missing ⚠️
...n/java/com/cloud/storage/VolumeApiServiceImpl.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.20    #9394      +/-   ##
============================================
- Coverage     15.81%   15.81%   -0.01%     
+ Complexity    12554    12553       -1     
============================================
  Files          5629     5629              
  Lines        492023   492023              
  Branches      62519    63929    +1410     
============================================
- Hits          77813    77812       -1     
  Misses       405887   405887              
- Partials       8323     8324       +1     
Flag Coverage Δ
uitests 4.48% <ø> (ø)
unittests 16.60% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@DaanHoogland
Copy link
Contributor

good code @FelipeM525, but is there a cause for this? I mean is there a plan to exploit this ?

@weizhouapache
Copy link
Member

good code @FelipeM525, but is there a cause for this? I mean is there a plan to exploit this ?

I have same questions

@FelipeM525
Copy link
Contributor Author

good code @FelipeM525, but is there a cause for this? I mean is there a plan to exploit this ?

Hello @DaanHoogland, Given the scope of Cloudstack and the number of people that work on this project, I believe it's important to emphasize keeping the code base clean by applying clean code principles and respecting the main concept of Java, which is OOP. Therefore, we should make sure classes have private access modifiers and that fields aren't accessed directly without getters so as to adhere to encapsulation.

Copy link
Contributor

@GaOrtiga GaOrtiga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLGTM

Copy link
Contributor

@JoaoJandre JoaoJandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLGTM

@JoaoJandre
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@JoaoJandre a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10397

@weizhouapache
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

@weizhouapache a [SL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian Build Failed (tid-10909)

@FelipeM525
Copy link
Contributor Author

FelipeM525 commented Aug 1, 2024

@weizhouapache could you run the test again?

@weizhouapache
Copy link
Member

@blueorangutan test rocky8 kvm-rocky8

@blueorangutan
Copy link

@weizhouapache a [SL] Trillian-Jenkins test job (rocky8 mgmt + kvm-rocky8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-11008)
Environment: kvm-rocky8 (x2), Advanced Networking with Mgmt server r8
Total time taken: 49272 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr9394-t11008-kvm-rocky8.zip
Smoke tests completed. 136 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_06_purge_expunged_vm_background_task Failure 332.10 test_purge_expunged_vms.py

@weizhouapache
Copy link
Member

@FelipeM525

  • hostip should be renamed to hostIp
  • getHostip and setHostip are not needed. there are already getHostIp and setHostIp

FelipeM525 added a commit to scclouds/cloudstack that referenced this pull request Aug 2, 2024
Copy link
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blueorangutan package

@JoaoJandre
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@JoaoJandre a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10673

@FelipeM525
Copy link
Contributor Author

@weizhouapache could you run tests?

@DaanHoogland
Copy link
Contributor

@blueorangutan LLtest

@blueorangutan
Copy link

@DaanHoogland a [LL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@github-actions
Copy link

github-actions bot commented Sep 9, 2024

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

…ere a field was being accessed without a getter
@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 11097

@DaanHoogland DaanHoogland added this to the 4.20.1.0 milestone Sep 16, 2024
@JoaoJandre
Copy link
Contributor

for the debian build I see

10:02:05 [ERROR] Failed to execute goal on project cloud-server: Could not resolve dependencies for project org.apache.cloudstack:cloud-server:jar:4.20.0.0-shapeblue11941: Could not transfer artifact org.slf4j:slf4j-api:jar:1.7.32 from/to central (https://repo.maven.apache.org/maven2): transfer failed for https://repo.maven.apache.org/maven2/org/slf4j/slf4j-api/1.7.32/slf4j-api-1.7.32.jar: Connection reset -> [Help 1]

I don't think we still have a slf4j dependency as it was removed and logging was consolidated to be all log4j2???

The log4j 1.2 dependency could not be completely removed because juniper contrail has log4j as a dependency. So we still have this dependency somewhere in the code.

Copy link
Contributor

@sureshanaparti sureshanaparti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm

@sureshanaparti
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 11295

Copy link
Contributor

@BryanMLima BryanMLima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLGTM

@BryanMLima
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@BryanMLima a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 11659

@DaanHoogland DaanHoogland changed the base branch from main to 4.20 December 2, 2024 08:51
@JoaoJandre
Copy link
Contributor

@DaanHoogland could we run the CI here?

@DaanHoogland
Copy link
Contributor

@DaanHoogland could we run the CI here?

@JoaoJandre , our lab has been very busy the last few days. I'll have a go later tonight or in the weekend.

@DaanHoogland
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@DaanHoogland
Copy link
Contributor

@FelipeM525 @JoaoJandre , I did not investigate deeply but systemVMs do not start in this env:

2024-12-05 10:28:41,870 ERROR [c.c.v.VmWorkJobDispatcher] (Work-Job-Executor-79:[ctx-d0456350, job-6/job-392]) logid:c2de6f47) Unable to complete AsyncJobVO: {id:392, userId: 1, accountId: 1, instanceType: null, instanceId: null, cmd: com.cloud.vm.VmWorkStart, cmdInfo: rO0ABXNyABhjb20uY2xvdWQudm0uVm1Xb3JrU3RhcnR9cMGsvxz73gIAC0oABGRjSWRMAAZhdm9pZHN0ADBMY29tL2Nsb3VkL2RlcGxveS9EZXBsb3ltZW50UGxhbm5lciRFeGNsdWRlTGlzdDtMAAljbHVzdGVySWR0ABBMamF2YS9sYW5nL0xvbmc7TAAGaG9zdElkcQB-AAJMAAtqb3VybmFsTmFtZXQAEkxqYXZhL2xhbmcvU3RyaW5nO0wAEXBoeXNpY2FsTmV0d29ya0lkcQB-AAJMAAdwbGFubmVycQB-AANMAAVwb2RJZHEAfgACTAAGcG9vbElkcQB-AAJMAAlyYXdQYXJhbXN0AA9MamF2YS91dGlsL01hcDtMAA1yZXNlcnZhdGlvbklkcQB-AAN4cgATY29tLmNsb3VkLnZtLlZtV29ya5-ZtlbwJWdrAgAESgAJYWNjb3VudElkSgAGdXNlcklkSgAEdm1JZEwAC2hhbmRsZXJOYW1lcQB-AAN4cAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAd3QAGVZpcnR1YWxNYWNoaW5lTWFuYWdlckltcGwAAAAAAAAAAHBwcHBwcHBwcHA, cmdVersion: 0, status: IN_PROGRESS, processStatus: 0, resultCode: 0, result: null, initMsid: 32986238026845, completeMsid: null, lastUpdated: null, lastPolled: null, created: Thu Dec 05 10:28:33 UTC 2024, removed: null}, job origin: 6 com.cloud.exception.InsufficientServerCapacityException: Unable to create a deployment for VM instance {"id":119,"instanceName":"s-119-VM","type":"SecondaryStorageVm","uuid":"7dd52cd9-eea0-419a-90f0-1fdc74f3d2c0"}Scope=interface com.cloud.dc.DataCenter; id=1
        at com.cloud.vm.VirtualMachineManagerImpl.orchestrateStart(VirtualMachineManagerImpl.java:1237)
        at com.cloud.vm.VirtualMachineManagerImpl.orchestrateStart(VirtualMachineManagerImpl.java:5467)
        at jdk.internal.reflect.GeneratedMethodAccessor290.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:569)
        at com.cloud.vm.VmWorkJobHandlerProxy.handleVmWorkJob(VmWorkJobHandlerProxy.java:106)
        at com.cloud.vm.VirtualMachineManagerImpl.handleVmWorkJob(VirtualMachineManagerImpl.java:5591)
        at com.cloud.vm.VmWorkJobDispatcher.runJob(VmWorkJobDispatcher.java:99)
        at org.apache.cloudstack.framework.jobs.impl.AsyncJobManagerImpl$5.runInContext(AsyncJobManagerImpl.java:652)
        at org.apache.cloudstack.managed.context.ManagedContextRunnable$1.run(ManagedContextRunnable.java:49)
        at org.apache.cloudstack.managed.context.impl.DefaultManagedContext$1.call(DefaultManagedContext.java:56)
        at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.callWithContext(DefaultManagedContext.java:103)
        at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.runWithContext(DefaultManagedContext.java:53)
        at org.apache.cloudstack.managed.context.ManagedContextRunnable.run(ManagedContextRunnable.java:46)
        at org.apache.cloudstack.framework.jobs.impl.AsyncJobManagerImpl$5.run(AsyncJobManagerImpl.java:600)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:840)

@DaanHoogland
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

[SF] Trillian Build Failed (tid-11856)

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 11724

@DaanHoogland
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-11859)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 56110 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr9394-t11859-kvm-ol8.zip
Smoke tests completed. 141 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@weizhouapache weizhouapache merged commit 810c410 into apache:4.20 Dec 6, 2024
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Dec 12, 2024
* added private access modifiers to VolumeVO and fixed an occurrence where a field was being accessed without a getter

* renamed the field hostip to hostIp and removed duplicated methods
apache#9394 (comment)
nicoschmdt pushed a commit to scclouds/cloudstack that referenced this pull request Feb 3, 2025
nicoschmdt pushed a commit to scclouds/cloudstack that referenced this pull request Feb 3, 2025
Port 4.20 -  Add access modifier to VolumeVO apache#9394

See merge request scclouds/scclouds!1057
@Pearl1594 Pearl1594 moved this to Done in ACS 4.20.1 Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

8 participants